<!DOCTYPE html>
<html xmlns:th="http://www.thymeleaf.org">
<head>
    <meta http-equiv="Cache-Control" content="no-cache, no-store, must-revalidate" />
    <meta http-equiv="Pragma" content="no-cache" />
    <meta http-equiv="Expires" content="0" />
    <link rel="Bookmark"  href="/favicon.ico" >
    <link rel="stylesheet" type="text/css" href="/layui.css"  media="all">
    <link rel="Shortcut Icon"  href="/favicon.ico" />
    <meta charset="UTF-8">
    <title>新增订阅</title>
</head>
<body>
<div class="page-container" style=" padding: 0;">
<form class="layui-form layui-form-pane" action="/addSubscribeByUser">
    <input type="hidden" id="model_id" name="model_id">
    <input type="hidden" id="type_id" name="type_id">
    <input type="hidden" id="uid" name="uid" th:value="${uid}">

    <div class="layui-form-item">
        <label class="layui-form-label">选择栏目</label>
        <div class="layui-input-block">
            <select name="" lay-filter="program">
                <option value="">请选择栏目</option>
                <option th:each="program:${programList}" th:value="${program.program_id}" th:text="${program.program_name}" ></option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">选择币种</label>
        <div class="layui-input-block">
            <select name="" lay-filter="coin" lay-search="">
                <option  value="">请选择币种</option>
                <option th:each="coinTemplateData:${coinTemplateDataList}" th:value="${coinTemplateData.cid}" th:text="${coinTemplateData.selectCoin}" ></option>
            </select>
        </div>
    </div>

    <div class="layui-form-item">
        <label class="layui-form-label">选择交易所</label>
        <div class="layui-input-block">
            <select name="" lay-filter="exchange">
                <option  value="">请选择交易所</option>
                <option th:each="exchange:${exchangeList}" th:value="${exchange.eid}" th:text="${exchange.ename}" ></option>
            </select>
        </div>
    </div>
    <div class="layui-form-item">
        <div id="button_relative" class="layui-input-block">
            <button   class="layui-btn" lay-submit   lay-filter="aa">立即提交</button>

        </div>
    </div>
</form>
</div>
<script type="text/javascript" src="/jquery.js"></script>
<script type="text/javascript" src="/layui.all.js"></script>
<script type="text/javascript" src="lib/layer/2.4/layer.js"></script>
<script type="text/javascript" >
    layui.use('form', function() {
        var form = layui.form; //只有执行了这一步，部分表单元素才会自动修饰成功
        form.on('select(coin)', function(data){
            if($("#type_id").val()!=2){
                layer.msg('非币种跟踪栏目下不可订阅该模型')
            }else {
                $("#model_id").attr("value",data.value);
            }
        });
        form.on('select(exchange)', function(data){
            if($("#type_id").val()!=3){
                layer.msg('非交易所公告栏目下不可订阅该模型')
            }else {
                $("#model_id").attr("value",data.value);
            }
        });
        form.on('select(program)', function(data){
            $("#type_id").attr("value",data.value);
        });
        form.on('submit(aa)',function () {
           var flag=true;
           if(($("#type_id").val()==2 || $("#type_id").val()==3) && $("#model_id").val()==0){
               layer.msg('订阅出错,请重新订阅,请关闭窗口重新订阅')
               flag=false;
           }
           if($("#type_id").val()==0){
               layer.msg('栏目不能为空')
               flag=false;
           }
            return flag;
        })
    });

    $(document).ready(function () {
        $("#model_id").attr("value",0);
        $("type_id").attr("value",0);
    })

</script>

</body>
</html>